﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="QuanLySoThuChi.aspx.cs" Inherits="ThuChi.QuanLySoThuChi" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
    .style9
    {
        width: 80px;
    }
    .style10
    {
    }
    .style14
    {
    }
    .style21
    {
        width: 214px;
    }
    .style23
    {
        width: 82px;
    }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" />
    <asp:LinqDataSource ID="LinqDataSourceSoThuChi" runat="server" 
        ContextTypeName="ThuChi.DCThuChiDataContext" EntityTypeName="" 
        TableName="SoThuChis" 
            onselecting="LinqDataSourceSoThuChi_Selecting">
    </asp:LinqDataSource>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
    <ProgressTemplate>
    <div align="center" style="background-color: #FFFAFA">
        <img alt="" src="App_Images/loading_icon%20(2).gif" align="middle" />
    </div>
    </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <div style="border: 2px solid #DBDDFF; line-height: 30px; background-color: #FFFAFA;" 
            align="left">
        <asp:LinkButton ID="lbtnThemPhieuThu0" runat="server" 
            onclick="lbtnThemPhieuThu_Click">Thêm phiếu thu</asp:LinkButton>
        &nbsp;<asp:LinkButton ID="lbtnThemPhieuChi0" runat="server" 
            onclick="lbtnThemPhieuChi_Click">Thêm phiếu chi</asp:LinkButton>
    </div>
    <asp:Panel ID="panCapNhatSoThuChi" runat="server" Visible="False">
    <table style="border: thin solid #dbddff; width: 100%;" cellpadding="4" 
        id="tblCapNhatSoThuChi" bgcolor="Snow">
        <tr>
            <td bgcolor="Lavender" colspan="2" 
                style="border: thin solid #dbddff; font-weight: 700; text-align: center;">
                <asp:Label ID="lblSoThuChi" runat="server">THÊM PHIẾU THU</asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style42" colspan="2" style="border: thin solid #dbddff;">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                <span style="font-size: 14px; ">Ngày:</span>
                    <asp:DropDownList ID="cboNgayGiaoDich" runat="server" 
                        Width="70px" 
                        Height="20px" 
                        style="margin-left: 0px" Font-Size="13px" 
                    onselectedindexchanged="cboNgayGiaoDich_SelectedIndexChanged" 
                        ToolTip="Ngày giao dịch">
                    </asp:DropDownList>
                &nbsp; <span style="font-size: 14px; ">Tháng:</span>
                    <asp:DropDownList ID="cboThangGiaoDich" runat="server" AutoPostBack="True" 
                        Width="70px" 
                        Height="20px" 
                        style="margin-left: 0px" Font-Size="13px" 
                    onselectedindexchanged="cboThangGiaoDich_SelectedIndexChanged" 
                        ToolTip="Tháng giao dịch">
                        <asp:ListItem Value="01">01</asp:ListItem>
                        <asp:ListItem Value="02">02</asp:ListItem>
                        <asp:ListItem Value="03">03</asp:ListItem>
                        <asp:ListItem>04</asp:ListItem>
                        <asp:ListItem>05</asp:ListItem>
                        <asp:ListItem Value="06">06</asp:ListItem>
                        <asp:ListItem>07</asp:ListItem>
                        <asp:ListItem>08</asp:ListItem>
                        <asp:ListItem>09</asp:ListItem>
                        <asp:ListItem>10</asp:ListItem>
                        <asp:ListItem>11</asp:ListItem>
                        <asp:ListItem>12</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp; <span style="font-size: 14px; ">Năm:</span>
                    <asp:DropDownList ID="cboNamGiaoDich" runat="server" 
                        Width="70px" 
                        Height="20px" 
                        style="margin-left: 0px" Font-Size="13px" 
                    onselectedindexchanged="cboNamGiaoDich_SelectedIndexChanged" 
                        ToolTip="Năm giao dịch">
                    </asp:DropDownList>
                    &nbsp;<asp:Label ID="lblErrorSoThuChi" runat="server" ForeColor="Red" 
                        style="margin-left: 0px"></asp:Label>
               </ContentTemplate>
               </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <td align="right" class="style23" style="border: thin solid #dbddff;" 
                valign="middle">
                <span style="font-size: 14px; ">Nhóm đối tác </span>
            </td>
            <td class="style14" style="border: thin solid #dbddff;" 
                valign="middle">
                <asp:Panel ID="Panel1" runat="server" DefaultButton="lbtnDongYNhom">
                <asp:DropDownList ID="cboNhom" runat="server" Height="21px" Width="251px" 
                    AutoPostBack="True" DataSourceID="LinqDataSourceNhom" DataTextField="TenNhom" 
                    DataValueField="MaNhom" 
                    onselectedindexchanged="cboNhom_SelectedIndexChanged">
                </asp:DropDownList>
&nbsp;<asp:LinkButton ID="lbtnThemNhom" runat="server" onclick="lbtnThemNhom_Click">Tạo mới</asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="lbtnSuaNhom" runat="server" onclick="lbtnSuaNhom_Click">Sửa</asp:LinkButton>
                    <asp:TextBox ID="txtTenNhom" runat="server" Height="22px" Visible="False" 
                        Width="229px"></asp:TextBox>
                    &nbsp;<asp:LinkButton ID="lbtnDongYNhom" runat="server" 
                        onclick="lbtnDongYNhom_Click" Visible="False">Đồng ý</asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="lbtnHuyBoNhom" runat="server" 
                        onclick="lbtnHuyBoNhom_Click" Visible="False">Hủy bỏ</asp:LinkButton>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td align="right" class="style23" style="border: thin solid #dbddff;" 
                valign="middle">
                <span style="font-size: 14px; ">Đối tác </span>
            </td>
            <td class="style10" style="border: thin solid #dbddff;" 
                valign="middle">
                <asp:Panel ID="Panel2" runat="server" DefaultButton="lbtnDongYDoiTac">
                <asp:DropDownList ID="cboDoiTac" runat="server" Height="21px" Width="251px" 
                    DataSourceID="LinqDataSourceDoiTac" DataTextField="TenDoiTac" 
                    DataValueField="MaDoiTac" onprerender="cboDoiTac_PreRender" 
                    AutoPostBack="True" ondatabound="cboDoiTac_DataBound" 
                    onselectedindexchanged="cboDoiTac_SelectedIndexChanged">
                </asp:DropDownList>
&nbsp;<asp:LinkButton ID="lbtnThemDoiTac" 
                    runat="server" onclick="lbtnThemDoiTac_Click">Tạo mới</asp:LinkButton>
&nbsp;</strong><asp:LinkButton ID="lbtnSuaDoiTac" runat="server" onclick="lbtnSuaDoiTac_Click">Sửa</asp:LinkButton>
                <asp:TextBox ID="txtTenDoiTac" runat="server" Height="22px" Visible="False" 
                    Width="229px"></asp:TextBox>
&nbsp;<asp:LinkButton ID="lbtnDongYDoiTac" runat="server" onclick="lbtnDongYDoiTac_Click" 
                    Visible="False">Đồng ý</asp:LinkButton>
            &nbsp;<asp:LinkButton ID="lbtnHuyBoDoiTac" runat="server" 
                    onclick="lbtnHuyBoDoiTac_Click" Visible="False">Hủy bỏ</asp:LinkButton>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td align="right" class="style23" style="border: thin solid #dbddff;" 
                valign="middle">
                <span style="font-size: 14px; ">Diễn giải </span>
            </td>
            <td class="style10" style="border: thin solid #dbddff;" 
                valign="middle">
                <asp:Panel ID="Panel3" runat="server" DefaultButton="lbtnDongYMuc">
                <asp:DropDownList ID="cboMuc" runat="server" Height="21px" Width="251px" 
                    DataSourceID="LinqDataSourceMuc" DataTextField="TenMuc" 
                    DataValueField="MaMuc" onprerender="cboMuc_PreRender" AutoPostBack="True" 
                    onselectedindexchanged="cboMuc_SelectedIndexChanged">
                </asp:DropDownList>&nbsp;<asp:LinkButton 
                    ID="lbtnThemMuc" runat="server" onclick="lbtnThemMuc_Click">Tạo mới</asp:LinkButton> &nbsp;<asp:LinkButton 
                    ID="lbtnSuaMuc" runat="server" onclick="lbtnSuaMuc_Click">Sửa</asp:LinkButton>
                <asp:TextBox ID="txtTenMuc" runat="server" Height="22px" Visible="False" 
                    Width="229px"></asp:TextBox>
&nbsp;<asp:LinkButton ID="lbtnDongYMuc" runat="server" onclick="lbtnDongYMuc_Click" 
                    Visible="False">Đồng ý</asp:LinkButton>
            &nbsp;<asp:LinkButton ID="lbtnHuyBoMuc" runat="server" onclick="lbtnHuyBoMuc_Click" 
                    Visible="False">Hủy bỏ</asp:LinkButton>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td align="right" class="style23" style="border: thin solid #dbddff;" 
                valign="middle">
                <span style="font-size: 14px; ">Số tiền </span>
            </td>
            <td class="style10" style="border: thin solid #dbddff;" 
                valign="middle">
                <asp:TextBox ID="txtSoTien" runat="server" Height="21px" style="text-align: right" 
                    Width="135px" MaxLength="13">1000</asp:TextBox>
                <ajaxToolkit:MaskedEditExtender ID="txtSoTien_MaskedEditExtender" 
                    runat="server" CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder="" 
                    CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder="" 
                    CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True" 
                    InputDirection="RightToLeft" Mask="9,999,999,999,999 đ" MaskType="Number" 
                    TargetControlID="txtSoTien">
                </ajaxToolkit:MaskedEditExtender>
            </td>
        </tr>
        <tr>
            <td align="right" class="style23" style="border: thin solid #dbddff;" 
                valign="middle">
                &nbsp;</td>
            <td class="style10" style="border: thin solid #dbddff;" 
                valign="middle">
                <asp:Button ID="btnCapNhat" runat="server" Text="Thêm" 
                    onclick="btnCapNhat_Click" />
&nbsp;<input id="Reset1" type="reset" value="Làm lại" onclick="return Reset1_onclick()" />
                <asp:Button ID="btnHuyBo" runat="server" onclick="btnHuyBo_Click" 
                    Text="Hủy bỏ" />
                    </td>
        </tr>
    </table>
    </asp:Panel>
    <table align="center" border="1px" cellpadding="4" 
        style="border: thin solid #dbddff; width: 100%;" 
            id="tblSoThuChi" bgcolor="Snow">
        <tr>
            <td colspan="2" align="center" bgcolor="Lavender" 
                style="border: thin solid #dbddff; font-weight: 700; text-align: center;">
                SỔ THU CHI</td>
        </tr>
               <tr>
            <td style="border: 2px solid #dbddff;" class="style21">
                <asp:LinkButton ID="lbtnThemPhieuThu" runat="server" 
                    onclick="lbtnThemPhieuThu_Click">Thêm phiếu thu</asp:LinkButton>
                &nbsp;<asp:LinkButton ID="lbtnThemPhieuChi" runat="server" 
                    onclick="lbtnThemPhieuChi_Click">Thêm phiếu chi</asp:LinkButton>
                &nbsp;</td>
            <td style="border: 2px solid #dbddff;">
                    <asp:Label ID="lblTongThu" runat="server" ForeColor="#0000EE"></asp:Label>
                    &nbsp;<asp:Label ID="lblTongChi" runat="server" ForeColor="#0000EE"></asp:Label>
                    &nbsp;<asp:Label ID="lblTon" runat="server" ForeColor="#0000EE"></asp:Label>
            </td>
        </tr>
        <tr>
                <td 
                    style="border: 2px solid #dbddff; font-size: 14px; " 
                    class="style21">
                    Loại phiếu:&nbsp;<asp:DropDownList 
                        ID="cboLoaiPhieu" runat="server" AutoPostBack="True" 
                        Width="135px" 
                        Height="20px" 
                        style="margin-left: 0px" Font-Size="13px" 
                        onselectedindexchanged="cboLoaiPhieu_SelectedIndexChanged">
                        <asp:ListItem Selected="True"></asp:ListItem>
                        <asp:ListItem Value="1">Phiếu thu</asp:ListItem>
                        <asp:ListItem Value="2">Phiếu chi</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td 
                    style="border: 2px solid #dbddff; font-size: 14px; " 
                    class="style22">
                    Ngày:
                    <asp:DropDownList ID="cboNgay" runat="server" 
                        Width="70px" 
                        Height="20px" 
                        style="margin-left: 0px" Font-Size="13px" 
                        onselectedindexchanged="cboNgay_SelectedIndexChanged" AutoPostBack="True" 
                        ToolTip="Ngày giao dịch">
                    </asp:DropDownList>
                &nbsp; Tháng:
                    <asp:DropDownList ID="cboThang" runat="server" AutoPostBack="True" 
                        Width="70px" 
                        Height="20px" 
                        style="margin-left: 0px" Font-Size="13px" 
                        onselectedindexchanged="cboThang_SelectedIndexChanged" 
                        ToolTip="Tháng giao dịch">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem Value="01">01</asp:ListItem>
                        <asp:ListItem Value="02">02</asp:ListItem>
                        <asp:ListItem Value="03">03</asp:ListItem>
                        <asp:ListItem>04</asp:ListItem>
                        <asp:ListItem>05</asp:ListItem>
                        <asp:ListItem Value="06">06</asp:ListItem>
                        <asp:ListItem>07</asp:ListItem>
                        <asp:ListItem>08</asp:ListItem>
                        <asp:ListItem>09</asp:ListItem>
                        <asp:ListItem>10</asp:ListItem>
                        <asp:ListItem>11</asp:ListItem>
                        <asp:ListItem>12</asp:ListItem>
                    </asp:DropDownList>
                &nbsp; Năm:
                    <asp:DropDownList ID="cboNam" runat="server" 
                        Width="70px" 
                        Height="20px" 
                        onselectedindexchanged="cboNam_SelectedIndexChanged" 
                        style="margin-left: 0px" Font-Size="13px" AutoPostBack="True" 
                        ToolTip="Năm giao dịch">
                    </asp:DropDownList>
                </td>
        </tr>
        <tr>
            <td colspan="2" style="border: 2px solid #dbddff;">
    <asp:GridView ID="grvSoThuChi" runat="server" AllowPaging="True" Width="100%" 
        AllowSorting="True" AutoGenerateColumns="False" CellPadding="6" 
        CssClass="DDGridView" 
        EnableModelValidation="False" 
        ShowFooter="True" ShowHeaderWhenEmpty="True" DataKeyNames="STT,MaDoiTac,MaMuc,NgayGiaoDich,SoPhieuThu,SoPhieuChi,SoTienThu,SoTienChi" 
        DataSourceID="LinqDataSourceSoThuChi" SelectedRowStyle-CssClass="DDSelected" 
                    onrowdatabound="grvSoThuChi_RowDataBound" 
                    onselectedindexchanged="grvSoThuChi_SelectedIndexChanged" 
                    onprerender="grvSoThuChi_PreRender" 
                    onpageindexchanging="grvSoThuChi_PageIndexChanging" 
                    onrowcommand="grvSoThuChi_RowCommand">
        <Columns>
            <asp:CommandField CancelText="Hủy bỏ" EditText="Sửa" 
                UpdateText="Cập nhật" DeleteText="Xóa" InsertText="Thêm" NewText="Tạo mới" 
                SelectText="Sửa" ShowSelectButton="True" >
            <FooterStyle Wrap="False" />
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:CommandField>
            <asp:ButtonField CommandName="Cancel" Text="Hủy bỏ">
            <HeaderStyle Wrap="True" />
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" 
                Wrap="False" />
            </asp:ButtonField>
            <asp:DynamicField DataField="NgayVaoSo" HeaderText="Ngày vào sổ" 
                ReadOnly="True" DataFormatString="{0:dd-MM-yyyy}" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
            </asp:DynamicField>
            <asp:DynamicField DataField="NgayGiaoDich" HeaderText="Ngày giao dịch" 
                DataFormatString="{0:dd-MM-yyyy}" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
            </asp:DynamicField>
            <asp:DynamicField DataField="DoiTac" HeaderText="Người - Đơn vị" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:DynamicField>
            <asp:DynamicField DataField="SoPhieuThu" HeaderText="Số phiếu thu" 
                ReadOnly="True" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:DynamicField>
            <asp:DynamicField DataField="SoPhieuChi" HeaderText="Số phiếu chi" 
                ReadOnly="True" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:DynamicField>
            <asp:DynamicField DataField="Muc" HeaderText="Diễn giải" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:DynamicField>
            <asp:DynamicField DataField="SoTienThu" HeaderText="Thu" 
                ReadOnly="True" DataFormatString="{0:N0}" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" />
            </asp:DynamicField>
            <asp:DynamicField DataField="SoTienChi" HeaderText="Chi" 
                ReadOnly="True" DataFormatString="{0:N0}" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" />
            </asp:DynamicField>
            <asp:DynamicField DataField="Ton" HeaderText="Tồn" ReadOnly="True" 
                DataFormatString="{0:N0}" />
            <asp:DynamicField DataField="STT" HeaderText="STT" Visible="False" >
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" />
            </asp:DynamicField>
        </Columns>
        <EditRowStyle Wrap="True" />
        <FooterStyle CssClass="DDFooter" Wrap="True" />
        <HeaderStyle HorizontalAlign="Center" CssClass="th" />
        <PagerSettings FirstPageImageUrl="~/DynamicData/Content/Images/PgFirst.gif" 
            FirstPageText="" LastPageImageUrl="~/DynamicData/Content/Images/PgLast.gif" 
            LastPageText="" Mode="NumericFirstLast" NextPageText="" PageButtonCount="8" 
            PreviousPageText="" />
        <PagerStyle CssClass="DDPager" />
        <RowStyle CssClass="td" />
<SelectedRowStyle CssClass="DDSelected"></SelectedRowStyle>
    </asp:GridView>
            </td>
        </tr>
        <tr>
            <td 
                style="border: 2px solid #dbddff; font-size: 14px; " 
                colspan="2">
                    Phân trang: 
                                                            <asp:DropDownList ID="cboPageSize" 
                        runat="server" AutoPostBack="True" 
                        Width="45px" 
                        Height="20px" 
 
                        style="margin-right: 0px; margin-left: 0px;" 
                        CssClass="style9" Font-Size="13px" 
                        onselectedindexchanged="cboPageSize_SelectedIndexChanged">
                        <asp:ListItem Value="1">1</asp:ListItem>
                        <asp:ListItem Selected="True">5</asp:ListItem>
                        <asp:ListItem>10</asp:ListItem>
                        <asp:ListItem>20</asp:ListItem>
                        <asp:ListItem>30</asp:ListItem>
                        <asp:ListItem>50</asp:ListItem>
                    </asp:DropDownList>
                </td>
        </tr>
    </table>
    </ContentTemplate>
    </asp:UpdatePanel>
    <asp:LinqDataSource ID="LinqDataSourceNhom" runat="server" 
        ContextTypeName="ThuChi.DCThuChiDataContext" EntityTypeName="" 
        TableName="Nhoms" 
        Where="MaTaiKhoan == @MaTaiKhoan" EnableDelete="True" EnableInsert="True" 
            EnableUpdate="True">
        <InsertParameters>
            <asp:SessionParameter DefaultValue="0" Name="MaTaiKhoan" 
                SessionField="MaTaiKhoan" Type="Int32" />
        </InsertParameters>
        <WhereParameters>
            <asp:SessionParameter DefaultValue="0" Name="MaTaiKhoan" 
                SessionField="MaTaiKhoan" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LinqDataSourceDoiTac" runat="server" 
        ContextTypeName="ThuChi.DCThuChiDataContext" EntityTypeName="" 
        TableName="DoiTacs" 
        Where="MaNhom == @MaNhom" EnableDelete="True" EnableInsert="True" 
            EnableUpdate="True">
        <InsertParameters>
            <asp:SessionParameter DefaultValue="0" Name="MaNhom" SessionField="MaNhom" 
                Type="Int32" />
        </InsertParameters>
        <WhereParameters>
            <asp:ControlParameter ControlID="cboNhom" DefaultValue="0" Name="MaNhom" 
                PropertyName="SelectedValue" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LinqDataSourceMuc" runat="server" 
        ContextTypeName="ThuChi.DCThuChiDataContext" EntityTypeName="" 
        TableName="Mucs" 
        Where="MaTaiKhoan == @MaTaiKhoan &amp;&amp; MaKhoan== @MaKhoan" 
        EnableUpdate="True" EnableDelete="True" EnableInsert="True">
        <InsertParameters>
            <asp:SessionParameter DefaultValue="0" Name="MaTaiKhoan" 
                SessionField="MaTaiKhoan" Type="Int32" />
            <asp:ControlParameter ControlID="cboKhoanFilter" DefaultValue="0" 
                Name="MaKhoan" PropertyName="SelectedValue" Type="Int32" />
        </InsertParameters>
        <WhereParameters>
            <asp:SessionParameter DefaultValue="0" Name="MaTaiKhoan" 
                SessionField="MaTaiKhoan" Type="Int32" />
            <asp:SessionParameter DefaultValue="0" Name="MaKhoan" SessionField="MaKhoan" 
                Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
</asp:Content>
